<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="main-content">
    <div class="box box-main">
        <form id="inputForm" model="post" action="<c:url value="/web/admin/enterprise/saveEnterpriseSysUser.action"/>"
              method="post" class="form-horizontal">
            <div class="box-body">
                <div class="form-unit">基本信息</div>
                <input name="enterpriseId" value="${enterprise.id}" type="hidden">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 管辖企业：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                ${enterprise.enterpriseName}
                                <%--<input path="postCode111" name="enterpriseName" value="${enterprise.enterpriseName}"
                                       maxlength="64" class="form-control required"/>--%>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> （登录账号）手机号：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input id="systemUserId" type="hidden" name="id">
                                <input path="postCode111" maxlength="64" id="userAccount" name="userAccount"
                                       class="form-control required"  onblur="findUser();"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 姓名：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="postCode111" maxlength="64" id="userName" name="userName"
                                       class="form-control required"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 登录密码：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="postCode111" type="password" maxlength="64" id="userPassword" name="userPassword"
                                       class="form-control required"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 确认密码：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="postCode111" type="password" maxlength="64"  equalto="#userPassword" id="repUserPassword" name="repUserPassword"
                                       class="form-control required"/>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-4 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

    function findUser() {
        if($.trim($("#userAccount").val())==""){
            return false;
        }
        $.ajax({
            url: "<c:url value="/web/admin/systemUser/findUserByAccount.action"/>",
            type: 'GET',
            dataType: 'JSON',
            data: {account: $("#userAccount").val()},
            success: function (result) {
                if(result.status===0){
                    var data = result.data;
                    $("#systemUserId").val(data.id);
                    $("#userName").val(data.userName);
                    $("#userPassword").val(data.userPassword);
                    $("#repUserPassword").val(data.userPassword);
                }else {
                    $("#systemUserId").val("");
                    $("#userName").val("");
                    $("#userPassword").val("");
                    $("#repUserPassword").val("");
                }
            }
        })
    }

    $("#inputForm").validate({
        submitHandler: function (form) {
            js.ajaxSubmitForm($(form), function (data) {
                // console.log(data);
                js.showMessage(data.msg);
                if (data.status == Global.NO) {
                    closeView();
                   // $('#dataGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });

    function closeView() {
        layer.close(LayWin['wSysUserEnterprise']);
    }
</script>


